#include "BlackBearFactory.h"

#include <QSqlDatabase>

#include "BBTable.h"
#include "BlackBear.h"
#include "SqlManager.h"
#include "Error.h"

BlackBearFactory* BlackBearFactory::m_instance = NULL;

BlackBearFactory* BlackBearFactory::instance()
{
	//Check if is the first time using
	if( m_instance == NULL )
	{
		m_instance = new BlackBearFactory();
	}

	return m_instance;
}

BlackBear* BlackBearFactory::connect( const QString& dataBaseName, const QString& userName, const QString& password, const QString& hostName )
{
	SqlManager* sqlManager = SqlManager::instance();

	BlackBear * blackBear = sqlManager->connect( dataBaseName, userName, password, hostName );

	if( blackBear == NULL )
	{
		ERR_ABORT( "Connection to database not exist" );
	}

	return blackBear;
}

/*
bool BlackBearFactory::createDataBase( const QString& hostName, const QString& dataBaseName, const QString& userName, const QString& password, const QString& xmlMappingFileName )
{
	//DOES NOTHING
	return false;
}
*/
